home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / misc / Fudgit233.lha / Source / examples / avg.ft < prev    next >
Encoding:
Text File  |  1993-12-14  |  366 b   |  23 lines

  1. # This file defines a function computing the average of a vector
  2. cmode
  3.     func avg(X) {
  4.         auto i,x
  5.  
  6.         for (x=0,i=1;i<=data;i++) {
  7.             x += X[i]
  8.         }
  9.         return(x/data)
  10.     }
  11. fmode
  12. # The following is equivalent
  13. cmode
  14.     func avg2(X) {
  15.         auto x, i=1        # By default x is 0
  16.  
  17.         while (i <= data) {
  18.             x += X[i++]
  19.         }
  20.         return (x/data)
  21.     }
  22. fmode
  23.